package com.chat.filter;


import javax.servlet.*;
import java.io.IOException;

/**
 * @Author: WFP
 * @Time: 2017/12/30
 * @decription:
 */
public class EncodingFilter implements Filter {

    private String charSet;
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        this.charSet = filterConfig.getInitParameter("charset");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding(this.charSet);
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
